define(['require', 'angular', 'framework/msg/GillionMsgModule'], function (require, angular) {
    return angular.module('TestMsgModule', ['GillionMsgModule'])
        .controller('TestMsgController', ['$scope', 'GillionMsg',function ($scope, GillionMsg) {

            $scope.show = function() {
                GillionMsg.show({
                    title:'提示',
                    msg:'恭喜你注册成功！恭喜你注册成功！恭喜你注册成功！恭喜你注册成功！恭喜你注册成功！',
                    timeout:3000,
                    icon: 'right',
                    onBeforeClose: function(){
                        console.log('onBeforeClose');
                    },
                    onClose: function(){
                        console.log('onClose');
                    },
                    onBeforeOpen: function(){
                        console.log('onBeforeOpen');
                    },
                    onOpen: function(){
                        console.log('onOpen');
                    },
                    buttons: [{
                        text:'确定',
                        type:'sure',
                        handler: function(){
                            console.log('你点击了确认');
                        }
                    },{
                        text:'取消',
                        type:'cancel',
                        handler: function(){
                            console.log('你点击了取消');
                        }
                    }]
                });
            };

            $scope.showUrl = function() {
                GillionMsg.showUrl( '提示','../dict/demo' );
            };

            $scope.alert = function() {
                GillionMsg.alert('提示信息','注册时即自动开通托管账户',
                    function(){
                        console.info('关闭提示');
                    },
                    {
                        modal: true
                    }
                );
            };

            $scope.confirm = function() {
                GillionMsg.confirm('提示信息','注册时即自动开通托管账户，同时进行实名认证并绑定手机号码。',
                    function(r){
                        console.info(r);
                    }
                );
            };

            $scope.wait = function() {
                $scope.dlgWait= GillionMsg.wait('提示信息', '努力加载中。。。');
            };

            $scope.closeWait = function(){
                $scope.dlgWait.close();
            };

            $scope.progress = function() {
                var prg = GillionMsg.progress('提示信息');

                var f = function(v){
                    return function(){
                        if(v == 12){
                            prg.close();
                        }else{
                            var i = v/11;
                            prg.updateProgress(Math.round(100*i));
                        }
                    };
                };
                for(var i = 1; i < 13; i++){
                    setTimeout(f(i), i*500);
                }
            };

        }]);
})